Conversation
divkam
commented
Feb 2, 2017
- added commands to read gas sensor firmware version, status register, error register
- command line support to test firmware update
- periodic upload of gas sensor firmware version as part of periodic protobuf (Fields for gas sensor fw update proto#145)
- not tested
|
|
||
| assert(xSemaphoreTakeRecursive(i2c_smphr, 30000)); | ||
|
|
||
| (I2C_IF_Write(tvoc_i2c_addr, i2c_payload, 9, 1)); |
There was a problem hiding this comment.
use the number of bytes read in, in case it's less than the i2c payload size
There was a problem hiding this comment.
the payload size has to be 9 though. if the bytes read is less, it breaks out of the loop
|
|
||
| res = hello_fs_read(&fp,&i2c_payload[1],bytes_to_read, &bytes_read); | ||
| } | ||
| LOGI("TV: program done. Bytes read: %d, res:%d\n", bytes_read, res); |
There was a problem hiding this comment.
Maybe LOGE if bytes_read != bytes_to_read
| (I2C_IF_Write(tvoc_i2c_addr, erase_cmd, 5, 1)); | ||
| xSemaphoreGiveRecursive(i2c_smphr); | ||
|
|
||
| vTaskDelay(500); |
There was a problem hiding this comment.
How much margin does this give?
There was a problem hiding this comment.
500ms delay is as recommended in the datasheet. The entire programming takes 3-5 seconds.
| LOGI("TVOC FW Filename:%s\n",bin_file); | ||
|
|
||
| // reset CCS811 | ||
| if(_tvoc_reset()){ |
There was a problem hiding this comment.
It may be better to get the I2C semaphore here and hold it for the entire process. The lock can still be left within the private functions in case they are called independently.
What happens if it is acquired for one step but not others?
| ********************************************************************************/ | ||
| bool tvoc_wa = false; | ||
| uint8_t tvoc_i2c_addr = 0x5A; | ||
| int init_tvoc(int measmode) { |
There was a problem hiding this comment.
Maybe add a check here in case the device has been put into a bad state by the update?
There was a problem hiding this comment.
Good idea, will do. thanks
- removed status register read before boot since the register contents are garbage - added check for app valid. if sensor is in a bad state after a fw update, the status register read after boot will indicate the same - use Uartprintf instead of LOGI because init_tvoc is called before uart logger init